
package progentiere.knapsackprb;

public class ProgEntiere {

    public static void main(String[] args) 
    {int[] seeds = {
  28657};
        // 100 seeds
        /*
        int[] seeds = {
  28657,  28661,  28663,  28669,  28687,  28697,  28703,  28711,  28723,  28729,
  28751,  28753,  28759,  28771,  28789,  28793,  28807,  28813,  28817,  28837, 
  28843,  28859,  28867,  28871,  28879,  28901,  28909,  28921,  28927,  28933, 
  28949,  28961,  28979,  29009,  29017,  29021,  29023,  29027,  29033,  29059, 
  29063,  29077,  29101,  29123,  29129,  29131,  29137,  29147,  29153,  29167, 
  29173,  29179,  29191,  29201,  29207,  29209,  29221,  29231,  29243,  29251, 
  29269,  29287,  29297,  29303,  29311,  29327,  29333,  29339,  29347,  29363, 
  29383,  29387,  29389,  29399,  29401,  29411,  29423,  29429,  29437,  29443, 
  29453,  29473,  29483,  29501,  29527,  29531,  29537,  29567,  29569,  29573, 
  29581,  29587,  29599,  29611,  29629,  29633,  29641,  29663,  29669,  29671};*/
        
        for (int nbItems = 50 ; nbItems <= 100 ; nbItems *= 10)
        {
            int nbSolved = 0;
            for (int seed : seeds)
            {
                //KnapSackProblem problem = new KnapSackProblem(10000, nbItems, new SpecializedBrandAndBound());
                //KnapSackProblem problem = new KnapSackProblem(10000, nbItems, new GreedyLPHeuristic());
                KnapSackProblem problem = new KnapSackProblem(10000, nbItems, new CoreDP());
                //KnapSackProblem problem = new KnapSackProblem(100, nbItems, new DPInteger());

                problem.generateAtRandom(seed, 0.1);
                problem.solve();
                if(problem.getSolution().isOptimal())
                {
                    nbSolved++;
                }
                System.out.println(problem.toString());
                System.out.println("profit = " + problem.getSolution().getProfit(problem));
                System.out.println("weight = " + problem.getSolution().getWeight(problem));
            }
            System.out.println("nbItems : " + nbItems + "; solved : " + nbSolved);
        }
    }

}
